package com.hj.surface;

import java.util.ArrayList;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder.Callback;
import android.view.SurfaceView;

/** 
 * ①展现游戏界面 
 * ②控制游戏界面 
 */  
public class MySurfaceView extends SurfaceView implements Callback, Runnable {

	private SurfaceHolder sh;//SurfaceView的管理器,不直接和SurfaceView打交道
	private boolean isDestroy = false;
	private Canvas canvas;//画纸
	private Paint paint;//画笔
	private int sW = 0;
	private int sH = 0;
	private ArrayList<Smile> list = new ArrayList<Smile>();
	private Resources res;
	
	/** 
     * ①绘制灰色背景 
     * ②绘制fps,帧率:每秒钟屏幕刷新的次数 
     * ③绘制按钮 
     * ④绘制小人,实现按钮的业务 
     * ⑤绘制笑脸 
     *  
     */
	public MySurfaceView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}
	

	public MySurfaceView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}


	public MySurfaceView(Context context) {
		super(context);

		res = context.getResources();
		init();
		sh = this.getHolder();
		sh.addCallback(this);
		
		paint = new Paint();//获取当前view管理者
		paint.setTextSize(30);
		paint.setAntiAlias(true);//设置搞锯齿
	}

	private Bitmap[] bm = new Bitmap[10];
	private int w1 = 0;
	private int w2 = 0;
	private int h1 = 0;
	private int h2 = 0;

	private void init() {
		//加载drable下的资源可以使用BitmapFactory
		
	}


	@Override
	public void run() {
		// TODO Auto-generated method stub

	}

	@Override
	public void surfaceCreated(SurfaceHolder holder) {
		// TODO Auto-generated method stub

	}

	@Override
	public void surfaceChanged(SurfaceHolder holder, int format, int width,
			int height) {
		// TODO Auto-generated method stub

	}

	@Override
	public void surfaceDestroyed(SurfaceHolder holder) {
		// TODO Auto-generated method stub

	}

}
